﻿using System.Collections.Generic;
using System.Drawing;
using ku.textumbruch.contract;
using ku.tokenizer.contract;
using ku.silbentrenner.contract;
using ku.reformatter.contract;
using ku.merger.contract;


namespace ku.textumbruch
{
    public class Textumbruch : ITextumbruch
    {
        private readonly ITokenizer _tokenizer;
        private readonly ISilbentrenner _silbentrenner;
        private readonly IMerger _merger;
        private readonly IReformatter _reformatter;

        public Textumbruch(ITokenizer tokenizer, ISilbentrenner silbentrenner, IMerger merger, IReformatter reformatter)
        {
            _tokenizer = tokenizer;
            _silbentrenner = silbentrenner;
            _merger = merger;
            _reformatter = reformatter;
        }


        public string Umbreche(string text, int zeilenlaenge)
        {
            var tokens = _tokenizer.Tokenize(text);
            var silben = _silbentrenner.Trenne(tokens);
            var merged = _merger.Merge(silben);
            return _reformatter.Reformat(merged, zeilenlaenge);
        }
    }
}
